package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.PayCompany;
import com.pgybook.db.entity.domain.PayCompanyEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PayCompanyMapper {
    int countByExample(PayCompanyEx example);

    int deleteByExample(PayCompanyEx example);

    @Delete({
            "delete from paycompany",
            "where PAYCOMPANYID = #{paycompanyid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer paycompanyid);

    @Insert({
            "insert into paycompany (COMPANYNAME, COMPANYCODE, ",
            "ADDRESS, CONTACT, ",
            "PHONE, DESCRIPTION, ",
            "CRTTIME, UPDTIME, ",
            "CRTSTAFF, UPDSTAFF)",
            "values (#{companyname,jdbcType=VARCHAR}, #{companycode,jdbcType=VARCHAR}, ",
            "#{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, ",
            "#{phone,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{updtime,jdbcType=TIMESTAMP}, ",
            "#{crtstaff,jdbcType=INTEGER}, #{updstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "paycompanyid", before = false, resultType = Integer.class)
    int insert(PayCompany record);

    int insertSelective(PayCompany record);

    List<PayCompany> selectByExample(PayCompanyEx example);

    @Select({
            "select",
            "PAYCOMPANYID, COMPANYNAME, COMPANYCODE, ADDRESS, CONTACT, PHONE, DESCRIPTION, ",
            "CRTTIME, UPDTIME, CRTSTAFF, UPDSTAFF",
            "from paycompany",
            "where PAYCOMPANYID = #{paycompanyid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    PayCompany selectByPrimaryKey(Integer paycompanyid);

    int updateByExampleSelective(@Param("record") PayCompany record, @Param("example") PayCompanyEx example);

    int updateByExample(@Param("record") PayCompany record, @Param("example") PayCompanyEx example);

    int updateByPrimaryKeySelective(PayCompany record);

    @Update({
            "update paycompany",
            "set COMPANYNAME = #{companyname,jdbcType=VARCHAR},",
            "COMPANYCODE = #{companycode,jdbcType=VARCHAR},",
            "ADDRESS = #{address,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER}",
            "where PAYCOMPANYID = #{paycompanyid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(PayCompany record);
}
